/*
 * BLinkLRT.java
 * 
 * Copyright 2008 David D. Emory
 * 
 * This file is part of Five Points. See <http://www.fpdev.org> for
 * additional information regarding the project.
 * 
 * Five Points is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Five Points is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Five Points.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.fpdev.core.basenet;

import java.awt.BasicStroke;
import java.awt.Color;
import org.fpdev.core.Scenario;
import org.fpdev.core.transit.TransitPath;
import org.fpdev.apps.rtemaster.gui.map.MapCanvas;

/**
 * The subclass of BLink for a light rail link.
 * 
 * @author demory
 */
public class BLinkLRT extends BLink {

  public BLinkLRT(Scenario s, int id, BNode fNode, BNode tNode, String dispName, int lenFt) {
    super(s, id, fNode, tNode, dispName, lenFt);
  }

  public BLinkLRT(BLink link) {
    super(link);
  }


  @Override
  public int getType() {
    return LinkTypes.TR_LRT;
  }

  @Override
  public int getClassType() {
    return BLink.CLASS_LRT;
  }

  @Override
  public void drawBG(MapCanvas canvas,Scenario scen) {
    canvas.setColor(new Color(0, 128, 0));
    canvas.setStroke(new BasicStroke(5));
    super.drawCurve(canvas);
  }

  @Override
  public void drawFG(MapCanvas canvas,Scenario scen) {
    canvas.setColor(Color.white);
    float[] dash = {5, 2};
    canvas.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, dash, 0));
    super.drawCurve(canvas);
  }

  @Override
  public int getDrawWidth(MapCanvas canvas,Scenario scen) {
    return 8;
  }

  @Override
  public String getDisplayText() {
    return "["+scenario_.getName()+"] LRT "+id_+" "+(getDisplayName().length() > 0 ? getDisplayName() : "(unnamed)") + " (" + fNode_.getID() + " to " + tNode_.getID() + ") / len="+getLengthFeet();
  }

  @Override
  public boolean isWalkable() {
    return false;
  }

  @Override
  public boolean isBikeable(BNode start) {
    return false;
  }

  @Override
  public boolean isMajor() {
    return true;
  }

  @Override
  public boolean supportsTransitType(TransitPath.Type type, Scenario scen, BaseNetwork baseNet) {
    return type == TransitPath.Type.LIGHTRAIL;
  }
}
